package biz.ezcom.design.pattern.interpreter;

/**
 * 解释器抽象 
 */
public abstract class AbstractExpression {
	public void interpret(Context context){
		String playText = context.getPlayText();
		if(playText == null || playText.length() == 0) {
			return;
		}
		
		String playKey = playText.substring(0,1);
		int index = playText.indexOf(" ",2);
		double playValue = Double.parseDouble(playText.substring(2,index));
		context.setPlayText(playText.substring(index+1));
		execute(playKey, playValue);
	}
	
	public abstract void execute(String key, double value);
}
